package com.apexedu.portal.controller;

import com.apexedu.framework.util.DBUtil;
import com.apexedu.identity.IdConstants;
import com.apexedu.identity.entity.TSysUser;
import com.apexedu.portal.constant.ActionConstant;
import com.apexedu.portal.constant.Constants;
import com.apexedu.portal.entity.Lbxx;
import com.apexedu.portal.entity.TCity;
import com.apexedu.portal.util.DBMUtil;
import com.apexedu.portal.util.LittleTimer;
import com.apexedu.util.StringUtil;
import com.apexedu.util.json.JsonUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;

/**
 * 门户4.0展示界面 上海工会
 * Created by ly on 2015/3/5.
 */
@Controller
public class MhShghglzyxyController extends BaseController {

    private static final String[] weeks = new String[]{"周日", "周一", "周二", "周三", "周四", "周五", "周六"};

    /**
     * 初始界面
     *
     * @return 初始界面
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_init, method = RequestMethod.GET)
    public String init(HttpServletRequest request) {
        debug("<<{}>> init start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            String type = getUsertype(request); //获取用户类型
            getWeather(request); //获取天气信息
            initTzgg(request, type); //初始化通知公告
            initDyfw(request, type); //初始化订阅服务
            return ActionConstant.MhShgh.Forward_init;
        } catch (Exception e) {
            error("<<{}>> init error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> init end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 初始化服务资源
     *
     * @param request --
     * @param type    用户类型 参考Constants.MhShghUserType
     */
    private void initDyfw(HttpServletRequest request, String type) {
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        String mrfwid = StringUtil.EMPTY; //默认服务id
        String dyfwid = StringUtil.EMPTY; //订阅服务id
        if (Constants.MhUserType.LS.equals(type)) { //教职工
            mrfwid = "server_WAR_nj612portlet_INSTANCE_aaiNF15s1md6";
            dyfwid = "server_WAR_nj612portlet_INSTANCE_7iINqGjAAV73";
        } else if (Constants.MhUserType.LD.equals(type)) { //校领导
            mrfwid = "server_WAR_nj612portlet_INSTANCE_iHP4bwLDiNYC";
            dyfwid = "server_WAR_nj612portlet_INSTANCE_BkG18oMpTY3V";
        } else if (Constants.MhUserType.XS.equals(type)) { //学生
            mrfwid = "server_WAR_nj612portlet_INSTANCE_b0pMQmbjftws";
            dyfwid = "server_WAR_nj612portlet_INSTANCE_8IoK6fuYENNz";
        }
        request.setAttribute("mrfw", getDyfwList(user.getUserloginid(), mrfwid));
        request.setAttribute("dyfw", getDyfwList(user.getUserloginid(), dyfwid));
        request.setAttribute("mrfwid", mrfwid);
        request.setAttribute("dyfwid", dyfwid);
    }

    /**
     * 获取服务集合json 校领导门户
     *
     * @param request
     * @return
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_getServer, method = RequestMethod.GET)
    @ResponseBody
    public String getServerJson(HttpServletRequest request) {
        debug("<<{}>> getServerJson start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            String userloginid = user.getUserloginid();
            StringBuffer sb = new StringBuffer("{\"xzbg\":");
            sb.append(JsonUtil.getJSONString(getDyfwList(userloginid, "navserver_WAR_nj612portlet_INSTANCE_hVunExHq6PNQ")));
            sb.append(",\"xsgz\":");
            sb.append(JsonUtil.getJSONString(getDyfwList(userloginid, "navserver_WAR_nj612portlet_INSTANCE_MRm2DnwdS8Lm")));
            sb.append(",\"hqzc\":");
            sb.append(JsonUtil.getJSONString(getDyfwList(userloginid, "navserver_WAR_nj612portlet_INSTANCE_Ll6bCiywMUpD")));
            sb.append("}");
            return sb.toString();
        } catch (Exception e) {
            error("<<{}>> getServerJson error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> getServerJson end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 初始化通知公告
     *
     * @param request
     */
    private void initTzgg(HttpServletRequest request, String type) throws Exception {
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        DBMUtil dbmUtil = new DBMUtil("oa");
        if (Constants.MhUserType.LS.equals(type)) { //教职工站点
            List<Lbxx> tzgg = getTzgg(dbmUtil, "2", null);
            request.setAttribute("tzgg", tzgg); //通知公告
            int tzggys = tzgg.size() % 7 == 0 ? tzgg.size() / 7 : (tzgg.size() / 7 + 1);
            request.setAttribute("tzggys", tzggys == 0 ? 1 : tzggys);//通知公告页数
            request.setAttribute("xydt", getTzgg(dbmUtil, "1", null)); //学院动态
            List<Lbxx> gzzd = getTzgg(dbmUtil, "9", null);//规章制度
            request.setAttribute("gzzd", gzzd);
            request.setAttribute("xxjl", getTzgg(dbmUtil, "6", null)); //学习交流
        } else if (Constants.MhUserType.LD.equals(type)) { //校领导站点
            List<Lbxx> tzgg = getTzgg(dbmUtil, "2", null);
            request.setAttribute("tzgg", tzgg); //通知公告
            int tzggys = tzgg.size() % 7 == 0 ? tzgg.size() / 7 : (tzgg.size() / 7 + 1);
            request.setAttribute("tzggys", tzggys == 0 ? 1 : tzggys);//通知公告页数
        } else if (Constants.MhUserType.XS.equals(type)) { //学生站点
            List<Lbxx> xydt = getTzgg(dbmUtil, "1", null);
            request.setAttribute("tzgg", xydt); //学院动态
            int xydtys = xydt.size() % 7 == 0 ? xydt.size() / 7 : (xydt.size() / 7 + 1);
            request.setAttribute("xydtys", xydtys == 0 ? 1 : xydtys);//学院动态页数
        }
        List<Lbxx> dbsy = getWorkflowNoFrame(user.getUserloginid());
        request.setAttribute("dbts", dbsy.size());
        request.setAttribute("dbsy", dbsy); //待办事宜

        Calendar cal = Calendar.getInstance();
        String week = weeks[cal.get(Calendar.DAY_OF_WEEK) - 1];
        request.setAttribute("weekday", week); //周几
        request.setAttribute("year", cal.get(Calendar.YEAR));
        request.setAttribute("month", cal.get(Calendar.MONTH) + 1);
        request.setAttribute("date", cal.get(Calendar.DAY_OF_MONTH));

        Object zc = new DBMUtil().queryFieldValue("select zbh from t_zc where to_char(sysdate,'yyyyMMdd') between to_char(ksrq,'yyyyMMdd') and to_char(jsrq,'yyyyMMdd')");
        request.setAttribute("zc", String.valueOf(zc));
    }

    /**
     * 获取天气信息
     *
     * @param request
     */
    private void getWeather(HttpServletRequest request) {
        TCity city = DBUtil.queryBean("select * from t_city", TCity.class);
        request.setAttribute("city", city);
        if (new Date().getTime() - city.getUpdatetime().getTime() > 1000 * 60 * 60) {
            request.setAttribute("isUpdate", "true"); //是否更新，一小时更新一次
        }
    }

    /**
     * 获取天气信息
     *
     * @return
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_getWeather, method = RequestMethod.GET)
    @ResponseBody
    public String getWeather() {
        LittleTimer timer = new LittleTimer(); // 计时器
        HttpURLConnection connection = null;
        InputStream inputStream = null;
        Reader reader = null;
        BufferedReader bufferedReader = null;
        try {
            String weatherUrl = "http://api.map.baidu.com/telematics/v3/weather?location=%E5%A5%89%E8%B4%A4&output=json&ak=1b7de2623d97e81ce2fe8e1d17967503";
            URL url = new URL(weatherUrl);
            connection = (HttpURLConnection) url.openConnection();
            connection.connect();
            inputStream = connection.getInputStream();

            reader = new InputStreamReader(inputStream, "UTF-8");
            bufferedReader = new BufferedReader(reader);
            String resultData = bufferedReader.readLine();
            return resultData;
        } catch (Exception e) {
            error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
            throw new RuntimeException(e);
        } finally {
            if (null != bufferedReader) {
                try {
                    bufferedReader.close();
                } catch (Exception e) {
                    error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
                }
            }
            if (null != reader) {
                try {
                    reader.close();
                } catch (Exception e) {
                    error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
                }
            }
            if (null != inputStream) {
                try {
                    inputStream.close();
                } catch (Exception e) {
                    error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
                }
            }
            if (null != connection) {
                try {
                    connection.disconnect();
                } catch (Exception e) {
                    error("<<{}>> getWeather error : {}", this.getClass().getSimpleName(), e); // 日志
                }
            }
            debug("<<{}>> getWeather end : {}", this.getClass().getSimpleName(), timer.end());// 计算方法执行时间
        }
    }

    /**
     * 保存天气信息
     *
     * @param request
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_saveWeather, method = RequestMethod.POST)
    @ResponseBody
    public void saveWeather(HttpServletRequest request) {
        debug("<<{}>> saveWeather start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            String weather = request.getParameter("weather");
            String tp = request.getParameter("tp");
            String temp1 = request.getParameter("t1");
            String temp2 = request.getParameter("t2");
            DBUtil.executeSQL("update t_city set temp1=?,temp2=?,weather=?,tp=?,updatetime=sysdate", temp1, temp2, weather, tp);
        } catch (Exception e) {
            error("<<{}>> saveWeather error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> saveWeather end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 周会议
     *
     * @return 周会议html代码
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_getZhy, method = RequestMethod.GET)
    @ResponseBody
    public String getZhy() {
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbutil = new DBMUtil("oa");
            /**
             * 查询OA数据库
             * t_zc 表
             * @参数 mc 名称
             * */
            String str = (String) dbutil.queryFieldValue("select to_char(zc.mc) from t_zc zc  where sysdate between zc.ksrq and zc.jsrq");
            String mc = str != null ? str : null;
            if (mc == null) {
//                throw new RuntimeException("一周会议无法获取周次名称!");
            }
            debug("<<{}>> doView : zc : {}", this.getClass().getSimpleName(), mc);

            String sql = "select (select to_char(min(gg.kssj),'D') from dual)week , '<span><strong>会议内容：</strong>' || ap.hynr ||  '</span><br><span><strong>会议室：</strong>' || "
                    + " (select wm_concat(hys.hytmc) from OA_T_HWGL_HYSGL hys "
                    + " where hys.id in (select hysap.ncyhys  from OA_T_HWGL_HYAPB_HYSSYSJ hysap "
                    + " where hysap.oa_t_hwgl_hyapb_id = ap.id)) || '</span><br><span><strong>责任部门：</strong>' || (select wm_concat(b.NAME) from lborganization b "
                    + "  where b.ID in (select * from table(split(ap.zbdw, ';')))) || '</span><br><span><strong>活动召集人：</strong>' || (select u.NAME from tuser u where u.id = ap.sqr) || '</span><br><span><strong>时间：</strong>' ||"
                    + " (select to_char(gg.kssj, 'hh24:mi:ss') || '-' ||  to_char(gg.jssj, 'hh24:mi:ss') from dual) || '</span><br><span><strong>参加领导：</strong>' || (select wm_concat(uu.NAME) "
                    + " from tuser uu  where instr(ap.chld, uu.id) > 0) || '</span><br><span><strong>参加人员：</strong>' || (select wm_concat(uu.NAME) from tuser uu "
                    + "where instr(ap.yhry, uu.id) > 0) || '</span><br><span><strong>校外来宾：</strong>' || ap.xwlb || '</span>'  as nr from OA_T_HWGL_HYAPB ap  "
                    + "left join t_zc zc on zc.id = ap.zc left join OA_T_HWGL_HYAPB_HYSSYSJ gg on ap.id=gg.oa_t_hwgl_hyapb_id "
                    + "where to_date(to_char(sysdate, 'yyyyMMdd'), 'yyyyMMdd') between zc.ksrq and zc.jsrq group by (gg.kssj,ap.hynr,ap.zbdw, ap.sqr,gg.jssj,ap.chld,ap.yhry,ap.xwlb,ap.id,ap.sqrq ) order by ap.sqrq, ap.id";

            List<Map<String, Object>> list = dbutil.queryForList(null, sql);
            StringBuffer sb = new StringBuffer("");
            for (int i = 0; i < 12; i++) {
                sb.append("<tr>");
                for (int j = 1; j <= 7; j++) {
                    sb.append("<td>");
                    for (Map<String, Object> map : list) {
                        if (j == Integer.parseInt(map.get("week").toString())) {
                            debug("<<{}>> doView : week : {}", this.getClass().getSimpleName(), map.get("week"));
                            sb.append("<div  titleDesc=\"" + map.get("nr") + "\"style=color:white;>※</div>");
                            debug("<<{}>> doView : nr : {}", this.getClass().getSimpleName(), map.get("nr"));
                            list.remove(map);
                            break;
                        }
                    }
                    sb.append("</td>");
                }
                sb.append("</tr>");
            }
            return sb.toString();
        } catch (Exception e) {
            error("<<{}>> getZhy error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> getZhy end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 教师课表
     *
     * @return 教师课表html代码
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_getJskb, method = RequestMethod.GET)
    @ResponseBody
    public String getJskb(HttpServletRequest request) {
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbutil = new DBMUtil();

            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            /**
             * 查询OA数据库
             * t_zc表
             * zbh 周编号
             */
            String sql;
            sql = "select zbh from t_zc where to_date(to_char(sysdate,'yyyyMMdd'),'yyyyMMdd') between ksrq and jsrq";
            BigDecimal obj = ((BigDecimal) dbutil.queryFieldValue(sql));
            String zbh = obj != null ? obj.toString() : null;
            /*
             * if (zbh == null) { throw new RuntimeException("教师课表无法获取周编号!"); }
			 */

            /**
             *
             * 查询门户数据库遍历教师数据
             * ●
             * @参数 zc 周次， 教师名称
             */
            sql = "select zj,jc,jsqc,kc,zc,bj,des from T_JSKB where zc=(select id from t_zc where to_date(to_char(sysdate,'yyyyMMdd'),'yyyyMMdd') between ksrq and jsrq) and jsmc=?";
            List<Map<String, Object>> list = dbutil.queryForList(null, sql, user.getUserloginid());
            StringBuffer sb = new StringBuffer();
            for (int i = 1; i <= 12; i++) {
                sb.append("<tr><td nowrap='nowrap'>" + "第" + i + "节" + "</td>");
                for (int j = 1; j <= 7; j++) {
                    sb.append("<td id='" + j + "_" + i + "'>");
                    for (Map<String, Object> map : list) {
                        if (j == Integer.parseInt(map.get("zj").toString()) && i == Integer.parseInt(map.get("jc").toString())) {
                            sb.append("<div titleDesc='" + "<span>教室：<span>" + map.get("jsqc") + "</br><span>课程：<span>" + map.get("kc")
                                    + "</br><span>班级：<span>" + map.get("bj") + "&nbsp;&nbsp;&nbsp;" + "'>" + map.get("des").toString() + "</div>");
                            break;
                        }
                    }
                    sb.append("</td>");
                }
                sb.append("</tr>");
            }
            request.setAttribute("teacherzbh", zbh);// 周次
            debug("<<{}>> doView , stHtml : {}", this.getClass().getSimpleName(), sb.toString());// 计算方法执行时间
            return sb.toString();
        } catch (Exception e) {
            error("<<{}>> doView error : {}", this.getClass().getSimpleName(), e); // 日志
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> doView end : {}", this.getClass().getSimpleName(), timer.end());// 计算方法执行时间
        }
    }

    /**
     * 学生课表
     *
     * @return 学生课表html代码
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_getXskb, method = RequestMethod.GET)
    @ResponseBody
    public String getXskb(HttpServletRequest request) {
        LittleTimer timer = new LittleTimer();
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            /**
             * 查找门户数据库
             * t_xskb 表
             * @参数 当前时间, 学生名称
             * */
            String sql = "select rq,zj,jc,js,kcmc,xm from T_xskb where rq=to_char(sysdate,'yyyyMMdd') and xm=?";
            List<Map<String, Object>> list = new DBMUtil().queryForList(null, sql, user.getUserloginid());
            StringBuffer sb = new StringBuffer();
            for (int i = 1; i <= 12; i++) {
                sb.append("<tr><th nowrap='nowrap' width='20%'>第" + i + "节</th><td width='80%'>&nbsp;");
                for (Map<String, Object> map : list) {
                    if (i == Integer.parseInt(map.get("jc").toString())) {
                        sb.append(map.get("kcmc") + "</br>");
                        sb.append(map.get("js"));
                        break;
                    }
                }
                sb.append("</td></tr>");
            }
            debug("<<{}>> doView , stHtml : {}", this.getClass().getSimpleName(), sb.toString());// 计算方法执行时间
            return sb.toString();
        } catch (Exception e) {
            error("<<{}>> doView error : {}", this.getClass().getSimpleName(), e); // 日志
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> doView end : {}", this.getClass().getSimpleName(), timer.end());// 计算方法执行时间
        }
    }

    /**
     * 一周会议界面
     *
     * @return 一周会议界面
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_yzhy, method = RequestMethod.GET)
    public String yzhy() {
        debug("<<{}>> yzhy start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            return ActionConstant.MhShgh.Forward_yzhy;
        } catch (Exception e) {
            error("<<{}>> yzhy error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> yzhy end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 行政管理界面
     *
     * @return 行政管理界面
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_xzgl, method = RequestMethod.GET)
    public String xzgl(HttpServletRequest request) {
        debug("<<{}>> xzgl start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            String mrfwid1 = "server_WAR_nj612portlet_INSTANCE_DKjVJwm45XyA";
            String mrfwid2 = "server_WAR_nj612portlet_INSTANCE_IlnaQGX7cTsb";
            String dyfwid = "server_WAR_nj612portlet_INSTANCE_RElw121qGL7m";
            request.setAttribute("mrfw1", getDyfwList(user.getUserloginid(), mrfwid1));
            request.setAttribute("mrfw2", getDyfwList(user.getUserloginid(), mrfwid2));
            request.setAttribute("dyfw", getDyfwList(user.getUserloginid(), dyfwid));
            request.setAttribute("mrfwid1", mrfwid1);
            request.setAttribute("mrfwid2", mrfwid2);
            request.setAttribute("dyfwid", dyfwid);

            DBMUtil dbmUtil = new DBMUtil("oa");
            List<Lbxx> hyjy = getTzgg(dbmUtil, "10", null);
            request.setAttribute("hyjy", hyjy); //会议纪要
            int hyjyys = hyjy.size() % 5 == 0 ? hyjy.size() / 5 : (hyjy.size() / 5 + 1);
            request.setAttribute("hyjyys", hyjyys == 0 ? 1 : hyjyys);//会议纪要页数
            return ActionConstant.MhShgh.Forward_xzgl;
        } catch (Exception e) {
            error("<<{}>> xzgl error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> xzgl end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 教学管理界面
     *
     * @return 教学管理界面
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_jxgl, method = RequestMethod.GET)
    public String jxgl(HttpServletRequest request) {
        debug("<<{}>> jxgl start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            String mrfwid = "server_WAR_nj612portlet_INSTANCE_WVsV7Cks8Fml"; //默认服务id
            String dyfwid = "server_WAR_nj612portlet_INSTANCE_Ujsz5hEtu1qL"; //订阅服务id
            request.setAttribute("mrfw", getDyfwList(user.getUserloginid(), mrfwid));
            request.setAttribute("dyfw", getDyfwList(user.getUserloginid(), dyfwid));
            request.setAttribute("mrfwid", mrfwid);
            request.setAttribute("dyfwid", dyfwid);

            DBMUtil dbmUtil = new DBMUtil("oa");
            List<Lbxx> jxdt = getTzgg(dbmUtil, "11", null);
            request.setAttribute("jxdt", jxdt); //教学动态
            int jxdtys = jxdt.size() % 5 == 0 ? jxdt.size() / 5 : (jxdt.size() / 5 + 1);
            request.setAttribute("jxdtys", jxdtys == 0 ? 1 : jxdtys);//教学动态页数
            request.setAttribute("tjwz", getTzgg(dbmUtil, "6", null)); //推荐文章
            return ActionConstant.MhShgh.Forward_jxgl;
        } catch (Exception e) {
            error("<<{}>> jxgl error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> jxgl end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 学生管理界面
     *
     * @return 学生管理界面
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_xsgl, method = RequestMethod.GET)
    public String xsgl(HttpServletRequest request) {
        debug("<<{}>> xsgl start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            String mrfwid = "server_WAR_nj612portlet_INSTANCE_0srJx9YexdvW"; //默认服务id
            String dyfwid = "server_WAR_nj612portlet_INSTANCE_vcS9Hz8r2mYO"; //订阅服务id
            request.setAttribute("mrfw", getDyfwList(user.getUserloginid(), mrfwid));
            request.setAttribute("dyfw", getDyfwList(user.getUserloginid(), dyfwid));
            request.setAttribute("mrfwid", mrfwid);
            request.setAttribute("dyfwid", dyfwid);

            DBMUtil dbmUtil = new DBMUtil("oa");
            List<Lbxx> xsgz = getTzgg(dbmUtil, "12", null);
            request.setAttribute("xsgz", xsgz); //学生工作
            int xsgzys = xsgz.size() % 5 == 0 ? xsgz.size() / 5 : (xsgz.size() / 5 + 1);
            request.setAttribute("xsgzys", xsgzys == 0 ? 1 : xsgzys);//学生工作页数
            return ActionConstant.MhShgh.Forward_xsgl;
        } catch (Exception e) {
            error("<<{}>> xsgl error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> xsgl end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 学生生活界面
     *
     * @return 学生生活界面
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_xssh, method = RequestMethod.GET)
    public String xssh(HttpServletRequest request) {
        debug("<<{}>> xssh start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            String mrfwid1 = "server_WAR_nj612portlet_INSTANCE_U721Ipo2e9qL";
            String mrfwid2 = "server_WAR_nj612portlet_INSTANCE_uxvxGNAOoF5A";
            String dyfwid = "server_WAR_nj612portlet_INSTANCE_5djdWcIRHahe";
            request.setAttribute("mrfw1", getDyfwList(user.getUserloginid(), mrfwid1));
            request.setAttribute("mrfw2", getDyfwList(user.getUserloginid(), mrfwid2));
            request.setAttribute("dyfw", getDyfwList(user.getUserloginid(), dyfwid));
            request.setAttribute("mrfwid1", mrfwid1);
            request.setAttribute("mrfwid2", mrfwid2);
            request.setAttribute("dyfwid", dyfwid);

            DBMUtil dbmUtil = new DBMUtil("oa");
            List<Lbxx> xsgz = getTzgg(dbmUtil, "12", null);
            request.setAttribute("xsgz", xsgz); //学生工作
            int xsgzys = xsgz.size() % 5 == 0 ? xsgz.size() / 5 : (xsgz.size() / 5 + 1);
            request.setAttribute("xsgzys", xsgzys == 0 ? 1 : xsgzys);//学生工作页数
            request.setAttribute("jxdt", getTzgg(dbmUtil, "11", null)); //教学动态
            return ActionConstant.MhShgh.Forward_xssh;
        } catch (Exception e) {
            error("<<{}>> xssh error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> xssh end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 就业指南界面
     *
     * @return 就业指南界面
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_jyzn, method = RequestMethod.GET)
    public String jyzn(HttpServletRequest request) {
        debug("<<{}>> jyzn start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            String mrfwid = "server_WAR_nj612portlet_INSTANCE_3bUTJZgjiiEb"; //默认服务id
            request.setAttribute("mrfw", getDyfwList(user.getUserloginid(), mrfwid));
            request.setAttribute("mrfwid", mrfwid);
            return ActionConstant.MhShgh.Forward_jyzn;
        } catch (Exception e) {
            error("<<{}>> jyzn error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> jyzn end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 图书社团
     *
     * @return 图书社团界面
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_tsst, method = RequestMethod.GET)
    public String tsst(HttpServletRequest request) {
        debug("<<{}>> tsst start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbmUtil = new DBMUtil("oa");
            List<Lbxx> tjwz = getTzgg(dbmUtil, "6", null);
            request.setAttribute("tjwz", tjwz); //推荐文章
            int tjwzys = tjwz.size() % 13 == 0 ? tjwz.size() / 13 : (tjwz.size() / 13 + 1);
            request.setAttribute("tjwzys", tjwzys == 0 ? 1 : tjwzys);//推荐文章页数
            request.setAttribute("gzzd", getTzgg(dbmUtil, "9", null)); //规则制度
            return ActionConstant.MhShgh.Forward_tsst;
        } catch (Exception e) {
            error("<<{}>> tsst error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> tsst end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }


    /**
     * 领导站点二级界面
     *
     * @param id      服务资源id
     * @param request --
     * @return 领导站点二级界面
     */
    @RequestMapping(value = ActionConstant.MhShgh.RequestMapping_servers, method = RequestMethod.GET)
    public String servers(@PathVariable(ActionConstant.Variable_Id) String id, HttpServletRequest request) {
        debug("<<{}>> servers start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            request.setAttribute("no", request.getParameter("no"));
            request.setAttribute("mrfw", getDyfwList(user.getUserloginid(), id));
            request.setAttribute("mrfwid", id);
            return ActionConstant.MhShgh.Forward_servers;
        } catch (Exception e) {
            error("<<{}>> servers error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> servers end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }
}